package com.webwork.lims.transport.dataobject;

import java.util.ArrayList;
import java.util.List;

import com.webwork.lims.common.dataobject.SuperEnum;

public enum TransStatus implements SuperEnum {

	NOSET(SuperEnum.NOSET_CODE, SuperEnum.NOSET_MSG),

	/**
	 * 等待出车
	 */
	WAITING(1, "等待出车"),
	/**
	 * 已发货
	 */
	DELIVERY(2, "已发货"),
	/**
	 * 已完成
	 */
	COMPLETE(3, "已完成"),
	/**
	 * 已取消
	 */
	CANCEL(4, "已取消");
	
	private Integer code;
	private String msg;
	
	private TransStatus(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	@Override
	public Integer getCode() {
		return code;
	}
	
	@Override
	public String getMsg() {
		return msg;
	}
	
	public static TransStatus[] useableValues() {
		List<TransStatus> ret = new ArrayList<TransStatus>();
		for (TransStatus o : TransStatus.values()) {
			if (o.code == TransStatus.NOSET_CODE) {
				continue;
			}
			ret.add(o);
		}
		return ret.toArray(new TransStatus[ret.size()]);
	}
	
	public static TransStatus fromCode(Integer code) {
		for (TransStatus o : TransStatus.values()) {
			if (o.code.equals(code)) {
				return o;
			}
		}
		throw new IllegalArgumentException(code.toString());
	}

}
